import {Injectable} from "@angular/core";

@Injectable()
export class UtilService {
  constructor(){

  }

  //将sword渲染过的日期字符串转为规范的日期格式字符串，例如：2018-04-26 14:13:29.0000 =》 2018-04-26 14:13:29
  public static toDateString(value:string){
    var re1='((?:2|1)\\d{3}(?:-|\\/)(?:(?:0[1-9])|(?:1[0-2]))(?:-|\\/)(?:(?:0[1-9])|(?:[1-2][0-9])|(?:3[0-1]))(?:T|\\s)(?:(?:[0-1][0-9])|(?:2[0-3])):(?:[0-5][0-9]):(?:[0-5][0-9]))';	// Time Stamp 1

    var p = new RegExp(re1,"i");
    var m = p.exec(value);
    if (m != null) {
      return m[1];
    } else {
      return value;
    }
  }
}
